home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / stdio / stdio.h < prev    next >
C/C++ Source or Header  |  1994-03-25  |  23KB  |  675 lines

  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    ANSI Standard: 4.9 INPUT/OUTPUT    <stdio.h>
  21.  */
  22.  
  23. #ifndef    _STDIO_H
  24.  
  25. #if    !defined(__need_FILE)
  26. #define    _STDIO_H    1
  27. #include <features.h>
  28.  
  29. __BEGIN_DECLS
  30.  
  31. #define    __need_size_t
  32. #define    __need_NULL
  33. #include <stddef.h>
  34.  
  35. #define    __need___va_list
  36. #include <stdarg.h>
  37. #ifndef    __GNUC_VA_LIST
  38. #define    __gnuc_va_list    __ptr_t
  39. #endif
  40.  
  41. #include <gnu/types.h>
  42. #endif /* Don't need FILE.  */
  43. #undef    __need_FILE
  44.  
  45.  
  46. #ifndef    __FILE_defined
  47.  
  48. /* The opaque type of streams.  */
  49. typedef struct __stdio_file FILE;
  50.  
  51. #define    __FILE_defined    1
  52. #endif /* FILE not defined.  */
  53.  
  54.  
  55. #ifdef    _STDIO_H
  56.  
  57. /* The type of the second argument to `fgetpos' and `fsetpos'.  */
  58. typedef __off_t fpos_t;
  59.  
  60. /* The mode of I/O, as given in the MODE argument to fopen, etc.  */
  61. typedef struct
  62. {
  63.   unsigned int __read:1;    /* Open for reading.  */
  64.   unsigned int __write:1;    /* Open for writing.  */
  65.   unsigned int __append:1;    /* Open for appending.  */
  66.   unsigned int __binary:1;    /* Opened binary.  */
  67.   unsigned int __create:1;    /* Create the file.  */
  68.   unsigned int __exclusive:1;    /* Error if it already exists.  */
  69.   unsigned int __truncate:1;    /* Truncate the file on opening.  */
  70. } __io_mode;
  71.  
  72.  
  73. /* Functions to do I/O and file management for a stream.  */
  74.  
  75. /* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.
  76.    Return number of bytes read.  */
  77. typedef __ssize_t __io_read_fn __P ((__ptr_t __cookie, char *__buf,
  78.                      size_t __nbytes));
  79.  
  80. /* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes
  81.    unless there is an error.  Return number of bytes written, or -1 if
  82.    there is an error without writing anything.  If the file has been
  83.    opened for append (__mode.__append set), then set the file pointer
  84.    to the end of the file and then do the write; if not, just write at
  85.    the current file pointer.  */
  86. typedef __ssize_t __io_write_fn __P ((__ptr_t __cookie, __const char *__buf,
  87.                       size_t __n));
  88.  
  89. /* Move COOKIE's file position to *POS bytes from the
  90.    beginning of the file (if W is SEEK_SET),
  91.    the current position (if W is SEEK_CUR),
  92.    or the end of the file (if W is SEEK_END).
  93.    Set *POS to the new file position.
  94.    Returns zero if successful, nonzero if not.  */
  95. typedef int __io_seek_fn __P ((__ptr_t __cookie, fpos_t *__pos, int __w));
  96.  
  97. /* Close COOKIE.  */
  98. typedef int __io_close_fn __P ((__ptr_t __cookie));
  99.  
  100. /* Return the file descriptor associated with COOKIE,
  101.    or -1 on error.  There need not be any associated file descriptor.  */
  102. typedef int __io_fileno_fn __P ((__ptr_t __cookie));
  103.  
  104. #ifdef __USE_GNU
  105. /* User-visible names for the above.  */
  106. typedef __io_read_fn cookie_read_function_t;
  107. typedef __io_write_fn cookie_write_function_t;
  108. typedef __io_seek_fn cookie_seek_function_t;
  109. typedef __io_close_fn cookie_close_function_t;
  110. typedef __io_fileno_fn cookie_fileno_function_t;
  111. #endif
  112.  
  113. /* Low level interface, independent of FILE representation.  */
  114. #if defined (__USE_GNU) && !defined (_LIBC)
  115. /* Define the user-visible type, with user-friendly member names.  */
  116. typedef struct
  117. {
  118.   __io_read_fn *read;        /* Read bytes.  */
  119.   __io_write_fn *write;        /* Write bytes.  */
  120.   __io_seek_fn *seek;        /* Seek/tell file position.  */
  121.   __io_close_fn *close;        /* Close file.  */
  122.   __io_fileno_fn *fileno;    /* Return file descriptor.  */
  123. } cookie_io_functions_t;
  124. /* This name is still used in the prototypes in this file.  */
  125. typedef cookie_io_functions_t __io_functions;
  126. #else
  127. /* Stick to ANSI-safe names.  */
  128. typedef struct
  129. {
  130.   __io_read_fn *__read;        /* Read bytes.  */
  131.   __io_write_fn *__write;    /* Write bytes.  */
  132.   __io_seek_fn *__seek;        /* Seek/tell file position.  */
  133.   __io_close_fn *__close;    /* Close file.  */
  134.   __io_fileno_fn *__fileno;    /* Return file descriptor.  */
  135. } __io_functions;
  136. #endif
  137.  
  138. /* Higher level interface, dependent on FILE representation.  */
  139. typedef struct
  140. {
  141.   /* Make room in the input buffer.  */
  142.   int (*__input) __P ((FILE *__stream));
  143.   /* Make room in the output buffer.  */
  144.   void (*__output) __P ((FILE *__stream, int __c));
  145. } __room_functions;
  146.  
  147. extern __const __io_functions __default_io_functions;
  148. extern __const __room_functions __default_room_functions;
  149.  
  150.  
  151. /* Default close function.  */
  152. extern __io_close_fn __stdio_close;
  153. /* Open FILE with mode M, store cookie in *COOKIEPTR.  */
  154. extern int __stdio_open __P ((__const char *__file, __io_mode __m,
  155.                   __ptr_t *__cookieptr));
  156. /* Put out an error message for when stdio needs to die.  */
  157. extern void __stdio_errmsg __P ((__const char *__msg, size_t __len));
  158. /* Generate a unique file name (and possibly open it with mode "w+b").  */
  159. extern char *__stdio_gen_tempname __P ((__const char *__dir,
  160.                     __const char *__pfx,
  161.                     int __dir_search,
  162.                     size_t *__lenptr,
  163.                     FILE **__streamptr));
  164.  
  165.  
  166. /* Print out MESSAGE on the error output and abort.  */
  167. extern __NORETURN void __libc_fatal __P ((__const char *__message));
  168.  
  169.  
  170. /* The FILE structure.  */
  171. struct __stdio_file
  172. {
  173.   /* Magic number for validation.  Must be negative in open streams
  174.      for the glue to Unix stdio getc/putc to work.
  175.      NOTE: stdio/glue.c has special knowledge of these first four members.  */
  176.   int __magic;
  177. #define    _IOMAGIC    0xfedabeeb    /* Magic number to fill `__magic'.  */
  178. #define    _GLUEMAGIC    0xfeedbabe    /* Magic for glued Unix streams.  */
  179.  
  180.   char *__bufp;            /* Pointer into the buffer.  */
  181.   char *__get_limit;        /* Reading limit.  */
  182.   char *__put_limit;        /* Writing limit.  */
  183.  
  184.   char *__buffer;        /* Base of buffer.  */
  185.   size_t __bufsize;        /* Size of the buffer.  */
  186.   __ptr_t __cookie;        /* Magic cookie.  */
  187.   __io_mode __mode;        /* File access mode.  */
  188.   __io_functions __io_funcs;    /* I/O functions.  */
  189.   __room_functions __room_funcs;/* I/O buffer room functions.  */
  190.   fpos_t __offset;        /* Current file position.  */
  191.   fpos_t __target;        /* Target file position.  */
  192.   FILE *__next;            /* Next FILE in the linked list.  */
  193.   char *__pushback_bufp;    /* Old bufp if char pushed back.  */
  194.   unsigned char __pushback;    /* Pushed-back character.  */
  195.   unsigned int __pushed_back:1;    /* A char has been pushed back.  */
  196.   unsigned int __eof:1;        /* End of file encountered.  */
  197.   unsigned int __error:1;    /* Error encountered.  */
  198.   unsigned int __userbuf:1;    /* Buffer from user (should not be freed).  */
  199.   unsigned int __linebuf:1;    /* Flush on newline.  */
  200.   unsigned int __linebuf_active:1; /* put_limit is not really in use.  */
  201.   unsigned int __seen:1;    /* This stream has been seen.  */
  202.   unsigned int __ispipe:1;    /* Nonzero if opened by popen.  */
  203. };
  204.  
  205.  
  206. /* All macros used internally by other macros here and by stdio functions begin
  207.    with `__'.  All of these may evaluate their arguments more than once.  */
  208.  
  209.  
  210. /* Nonzero if STREAM is a valid stream.
  211.    STREAM must be a modifiable lvalue (wow, I got to use that term).
  212.    See stdio/glue.c for what the confusing bit is about.  */
  213. #define    __validfp(stream)                              \
  214.   (stream != NULL &&                                  \
  215.    ((stream->__magic == _GLUEMAGIC &&                          \
  216.      (stream = *(((struct { int __magic; FILE **__p; } *) stream)->__p))),    \
  217.     (stream->__magic == _IOMAGIC)))
  218.  
  219. /* Clear the error and EOF indicators of STREAM.  */
  220. #define    __clearerr(stream)    ((stream)->__error = (stream)->__eof = 0)
  221.  
  222. /* Nuke STREAM, making it unusable but available for reuse.  */
  223. extern void __invalidate __P ((FILE *__stream));
  224.  
  225. /* Make sure STREAM->__offset and STREAM->__target are initialized.
  226.    Returns 0 if successful, or EOF on
  227.    error (but doesn't set STREAM->__error).  */
  228. extern int __stdio_check_offset __P ((FILE *__stream));
  229.  
  230.  
  231. /* The possibilities for the third argument to `setvbuf'.  */
  232. #define _IOFBF    0x1        /* Full buffering.  */
  233. #define _IOLBF    0x2        /* Line buffering.  */
  234. #define _IONBF    0x4        /* No buffering.  */
  235.  
  236.  
  237. /* Default buffer size.  */
  238. #define    BUFSIZ    1024
  239.  
  240.  
  241. /* End of file character.
  242.    Some things throughout the library rely on this being -1.  */
  243. #define    EOF    (-1)
  244.  
  245.  
  246. /* The possibilities for the third argument to `fseek'.
  247.    These values should not be changed.  */
  248. #define    SEEK_SET    0    /* Seek from beginning of file.  */
  249. #define    SEEK_CUR    1    /* Seek from current position.  */
  250. #define    SEEK_END    2    /* Seek from end of file.  */
  251.  
  252.  
  253. #ifdef    __USE_SVID
  254. /* Default path prefix for `tempnam' and `tmpnam'.  */
  255. #define    P_tmpdir    "/usr/tmp"
  256. #endif
  257.  
  258.  
  259. /* Get the values:
  260.    L_tmpnam    How long an array of chars must be to be passed to `tmpnam'.
  261.    TMP_MAX    The minimum number of unique filenames generated by tmpnam
  262.            (and tempnam when it uses tmpnam's name space),
  263.         or tempnam (the two are separate).
  264.    L_ctermid    How long an array to pass to `ctermid'.
  265.    L_cuserid    How long an array to pass to `cuserid'.
  266.    FOPEN_MAX    Mininum number of files that can be open at once.
  267.    FILENAME_MAX    Maximum length of a filename.  */
  268. #include <stdio_lim.h>
  269.  
  270.  
  271. /* All the known streams are in a linked list
  272.    linked by the `next' field of the FILE structure.  */
  273. extern FILE *__stdio_head;    /* Head of the list.  */
  274.  
  275. /* Standard streams.  */
  276. extern FILE *stdin, *stdout, *stderr;
  277.  
  278.  
  279. /* Remove file FILENAME.  */
  280. extern int remove __P ((__const char *__filename));
  281. /* Rename file OLD to NEW.  */
  282. extern int rename __P ((__const char *__old, __const char *__new));
  283.  
  284.  
  285. /* Create a temporary file and open it read/write.  */
  286. extern FILE *tmpfile __P ((void));
  287. /* Generate a temporary filename.  */
  288. extern char *tmpnam __P ((char *__s));
  289.  
  290.  
  291. #ifdef    __USE_SVID
  292. /* Generate a unique temporary filename using up to five characters of PFX
  293.    if it is not NULL.  The directory to put this file in is searched for
  294.    as follows: First the environment variable "TMPDIR" is checked.
  295.    If it contains the name of a writable directory, that directory is used.
  296.    If not and if DIR is not NULL, that value is checked.  If that fails,
  297.    P_tmpdir is tried and finally "/tmp".  The storage for the filename
  298.    is allocated by `malloc'.  */
  299. extern char *tempnam __P ((__const char *__dir, __const char *__pfx));
  300. #endif
  301.  
  302.  
  303. /* This performs actual output when necessary, flushing
  304.    STREAM's buffer and optionally writing another character.  */
  305. extern int __flshfp __P ((FILE *__stream, int __c));
  306.  
  307.  
  308. /* Close STREAM, or all streams if STREAM is NULL.  */
  309. extern int fclose __P ((FILE *__stream));
  310. /* Flush STREAM, or all streams if STREAM is NULL.  */
  311. extern int fflush __P ((FILE *__stream));
  312.  
  313.  
  314. /* Open a file and create a new stream for it.  */
  315. extern FILE *fopen __P ((__const char *__filename, __const char *__modes));
  316. /* Open a file, replacing an existing stream with it. */
  317. extern FILE *freopen __P ((__const char *__filename,
  318.                __const char *__modes, FILE *__stream));
  319.  
  320. /* Return a new, zeroed, stream.
  321.    You must set its cookie and io_mode.
  322.    The first operation will give it a buffer unless you do.
  323.    It will also give it the default functions unless you set the `seen' flag.
  324.    The offset is set to -1, meaning it will be determined by doing a
  325.    stationary seek.  You can set it to avoid the initial tell call.
  326.    The target is set to -1, meaning it will be set to the offset
  327.    before the target is needed.
  328.    Returns NULL if a stream can't be created.  */
  329. extern FILE *__newstream __P ((void));
  330.  
  331. #ifdef    __USE_POSIX
  332. /* Create a new stream that refers to an existing system file descriptor.  */
  333. extern FILE *fdopen __P ((int __fd, __const char *__modes));
  334. #endif
  335.  
  336. #ifdef    __USE_GNU
  337. /* Create a new stream that refers to the given magic cookie,
  338.    and uses the given functions for input and output.  */
  339. extern FILE *fopencookie __P ((__ptr_t __magic_cookie, __const char *__modes,
  340.                    __io_functions __io_funcs));
  341.  
  342. /* Create a new stream that refers to a memory buffer.  */
  343. extern FILE *fmemopen __P ((__ptr_t __s, size_t __len, __const char *__modes));
  344.  
  345. /* Open a stream that writes into a malloc'd buffer that is expanded as
  346.    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
  347.    and the number of characters written on fflush or fclose.  */
  348. extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc));
  349. #endif
  350.  
  351.  
  352. /* If BUF is NULL, make STREAM unbuffered.
  353.    Else make it use buffer BUF, of size BUFSIZ.  */
  354. extern void setbuf __P ((FILE *__stream, char *__buf));
  355. /* Make STREAM use buffering mode MODE.
  356.    If BUF is not NULL, use N bytes of it for buffering;
  357.    else allocate an internal buffer N bytes long.  */
  358. extern int setvbuf __P ((FILE *__stream, char *__buf,
  359.              int __modes, size_t __n));
  360.  
  361. #ifdef    __USE_BSD
  362. /* If BUF is NULL, make STREAM unbuffered.
  363.    Else make it use SIZE bytes of BUF for buffering.  */
  364. extern void setbuffer __P ((FILE *__stream, char *__buf, size_t __size));
  365.  
  366. /* Make STREAM line-buffered.  */
  367. extern void setlinebuf __P ((FILE *__stream));
  368. #endif
  369.  
  370.  
  371. /* Write formatted output to STREAM.  */
  372. extern int fprintf __P ((FILE *__stream, __const char *__format, ...));
  373. /* Write formatted output to stdout.  */
  374. extern int printf __P ((__const char *__format, ...));
  375. /* Write formatted output to S.  */
  376. extern int sprintf __P ((char *__s, __const char *__format, ...));
  377.  
  378. /* Write formatted output to S from argument list ARG.  */
  379. extern int vfprintf __P ((FILE *__s, __const char *__format,
  380.               __gnuc_va_list __arg));
  381. /* Write formatted output to stdout from argument list ARG.  */
  382. extern int vprintf __P ((__const char *__format, __gnuc_va_list __arg));
  383. /* Write formatted output to S from argument list ARG.  */
  384. extern int vsprintf __P ((char *__s, __const char *__format,
  385.               __gnuc_va_list __arg));
  386.  
  387. #ifdef    __OPTIMIZE__
  388. extern __inline int
  389. vprintf (const char *__fmt, __gnuc_va_list __arg)
  390. {
  391.   return vfprintf (stdout, __fmt, __arg);
  392. }
  393. #endif /* Optimizing.  */
  394.  
  395. #ifdef    __USE_GNU
  396. /* Maximum chars of output to write in MAXLEN.  */
  397. extern int snprintf __P ((char *__s, size_t __maxlen,
  398.               __const char *__format, ...));
  399.  
  400. extern int vsnprintf __P ((char *__s, size_t __maxlen,
  401.                __const char *__format, __gnuc_va_list __arg));
  402.  
  403. /* Write formatted output to a string dynamically allocated with `malloc'.
  404.    Store the address of the string in *PTR.  */
  405. extern int vasprintf __P ((char **__ptr, __const char *__f,
  406.                __gnuc_va_list __arg));
  407. extern int asprintf __P ((char **__ptr, __const char *__fmt, ...));
  408.  
  409. /* Write formatted output to a file descriptor.  */
  410. extern int vdprintf __P ((int __fd, __const char *__fmt,
  411.               __gnuc_va_list __arg));
  412. extern int dprintf __P ((int __fd, __const char *__fmt, ...));
  413. #endif
  414.  
  415.  
  416. /* Read formatted input from STREAM.  */
  417. extern int fscanf __P ((FILE *__stream, __const char *__format, ...));
  418. /* Read formatted input from stdin.  */
  419. extern int scanf __P ((__const char *__format, ...));
  420. /* Read formatted input from S.  */
  421. extern int sscanf __P ((__const char *__s, __const char *__format, ...));
  422.  
  423. #ifdef    __USE_GNU
  424. /* Read formatted input from S into argument list ARG.  */
  425. extern int __vfscanf __P ((FILE *__s, __const char *__format,
  426.                __gnuc_va_list __arg));
  427. extern int vfscanf __P ((FILE *__s, __const char *__format,
  428.              __gnuc_va_list __arg));
  429.  
  430. /* Read formatted input from stdin into argument list ARG.  */
  431. extern int vscanf __P ((__const char *__format, __gnuc_va_list __arg));
  432.  
  433. /* Read formatted input from S into argument list ARG.  */
  434. extern int __vsscanf __P ((__const char *__s, __const char *__format,
  435.                __gnuc_va_list __arg));
  436. extern int vsscanf __P ((__const char *__s, __const char *__format,
  437.              __gnuc_va_list __arg));
  438.  
  439.  
  440. #ifdef    __OPTIMIZE__
  441. extern __inline int
  442. vfscanf (FILE *__s, const char *__fmt, __gnuc_va_list __arg)
  443. {
  444.   return __vfscanf (__s, __fmt, __arg);
  445. }
  446. extern __inline int
  447. vscanf (const char *__fmt, __gnuc_va_list __arg)
  448. {
  449.   return __vfscanf (stdin, __fmt, __arg);
  450. }
  451. extern __inline int
  452. vsscanf (const char *__s, const char *__fmt, __gnuc_va_list __arg)
  453. {
  454.   return __vsscanf (__s, __fmt, __arg);
  455. }
  456. #endif /* Optimizing.  */
  457. #endif /* Use GNU.  */
  458.  
  459.  
  460. /* This does actual reading when necessary, filling STREAM's
  461.    buffer and returning the first character in it.  */
  462. extern int __fillbf __P ((FILE *__stream));
  463.  
  464.  
  465. /* Read a character from STREAM.  */
  466. extern int fgetc __P ((FILE *__stream));
  467. extern int getc __P ((FILE *__stream));
  468.  
  469. /* Read a character from stdin.  */
  470. extern int getchar __P ((void));
  471.  
  472. /* The C standard explicitly says this can
  473.    re-evaluate its argument, so it does. */
  474. #define    __getc(stream)                                  \
  475.   ((stream)->__bufp < (stream)->__get_limit ?                      \
  476.    (int) ((unsigned char) *(stream)->__bufp++) : __fillbf(stream))
  477.  
  478. /* The C standard explicitly says this is a macro,
  479.    so we always do the optimization for it.  */
  480. #define    getc(stream)    __getc(stream)
  481.  
  482. #ifdef    __OPTIMIZE__
  483. extern __inline int
  484. getchar (void)
  485. {
  486.   return __getc (stdin);
  487. }
  488. #endif /* Optimizing.  */
  489.  
  490.  
  491. /* Write a character to STREAM.  */
  492. extern int fputc __P ((int __c, FILE *__stream));
  493. extern int putc __P ((int __c, FILE *__stream));
  494.  
  495. /* Write a character to stdout.  */
  496. extern int putchar __P ((int __c));
  497.  
  498.  
  499. /* The C standard explicitly says this can
  500.    re-evaluate its arguments, so it does.  */
  501. #define    __putc(c, stream)                              \
  502.   ((stream)->__bufp < (stream)->__put_limit ?                      \
  503.    (int) (unsigned char) (*(stream)->__bufp++ = (unsigned char) (c)) :          \
  504.    __flshfp ((stream), (unsigned char) (c)))
  505.  
  506. /* The C standard explicitly says this can be a macro,
  507.    so we always do the optimization for it.  */
  508. #define    putc(c, stream)    __putc ((c), (stream))
  509.  
  510. #ifdef __OPTIMIZE__
  511. extern __inline int
  512. putchar (int __c)
  513. {
  514.   return __putc (__c, stdout);
  515. }
  516. #endif
  517.  
  518.  
  519. #if defined(__USE_SVID) || defined(__USE_MISC)
  520. /* Get a word (int) from STREAM.  */
  521. extern int getw __P ((FILE *__stream));
  522.  
  523. /* Write a word (int) to STREAM.  */
  524. extern int putw __P ((int __w, FILE *__stream));
  525. #endif
  526.  
  527.  
  528. /* Get a newline-terminated string of finite length from STREAM.  */
  529. extern char *fgets __P ((char *__s, size_t __n, FILE *__stream));
  530.  
  531. /* Get a newline-terminated string from stdin, removing the newline.
  532.    DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
  533. extern char *gets __P ((char *__s));
  534.  
  535.  
  536. #ifdef    __USE_GNU
  537. #include <sys/types.h>
  538.  
  539. /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
  540.    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
  541.    NULL), pointing to *N characters of space.  It is realloc'd as
  542.    necessary.  Returns the number of characters read (not including the
  543.    null terminator), or -1 on error or EOF.  */
  544. ssize_t __getdelim __P ((char **__lineptr, size_t *__n,
  545.              int __delimiter, FILE *__stream));
  546. ssize_t getdelim __P ((char **__lineptr, size_t *__n,
  547.                int __delimiter, FILE *__stream));
  548.  
  549. /* Like `getdelim', but reads up to a newline.  */
  550. ssize_t __getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
  551. ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
  552.  
  553. #ifdef    __OPTIMIZE__
  554. extern __inline ssize_t
  555. __getline (char **__lineptr, size_t *__n, FILE *__stream)
  556. {
  557.   return __getdelim (__lineptr, __n, '\n', __stream);
  558. }
  559.  
  560. extern __inline ssize_t
  561. getdelim (char **__lineptr, size_t *__n, int __delimiter, FILE *__stream)
  562. {
  563.   return __getdelim (__lineptr, __n, __delimiter, __stream);
  564. }
  565. extern __inline ssize_t
  566. getline (char **__lineptr, size_t *__n, FILE *__stream)
  567. {
  568.   return __getline (__lineptr, __n, __stream);
  569. }
  570. #endif /* Optimizing.  */
  571. #endif
  572.  
  573.  
  574. /* Write a string to STREAM.  */
  575. extern int fputs __P ((__const char *__s, FILE *__stream));
  576. /* Write a string, followed by a newline, to stdout.  */
  577. extern int puts __P ((__const char *__s));
  578.  
  579.  
  580. /* Push a character back onto the input buffer of STREAM.  */
  581. extern int ungetc __P ((int __c, FILE *__stream));
  582.  
  583.  
  584. /* Read chunks of generic data from STREAM.  */
  585. extern size_t fread __P ((__ptr_t __ptr, size_t __size,
  586.               size_t __n, FILE *__stream));
  587. /* Write chunks of generic data to STREAM.  */
  588. extern size_t fwrite __P ((__const __ptr_t __ptr, size_t __size,
  589.                size_t __n, FILE *__s));
  590.  
  591.  
  592. /* Seek to a certain position on STREAM.  */
  593. extern int fseek __P ((FILE *__stream, long int __off, int __whence));
  594. /* Return the current position of STREAM.  */
  595. extern long int ftell __P ((FILE *__stream));
  596. /* Rewind to the beginning of STREAM.  */
  597. extern void rewind __P ((FILE *__stream));
  598.  
  599. /* Get STREAM's position.  */
  600. extern int fgetpos __P ((FILE *__stream, fpos_t *__pos));
  601. /* Set STREAM's position.  */
  602. extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
  603.  
  604.  
  605. /* Clear the error and EOF indicators for STREAM.  */
  606. extern void clearerr __P ((FILE *__stream));
  607. /* Return the EOF indicator for STREAM.  */
  608. extern int feof __P ((FILE *__stream));
  609. /* Return the error indicator for STREAM.  */
  610. extern int ferror __P ((FILE *__stream));
  611.  
  612. #ifdef    __OPTIMIZE__
  613. #define    feof(stream)    ((stream)->__eof != 0)
  614. #define    ferror(stream)    ((stream)->__error != 0)
  615. #endif /* Optimizing.  */
  616.  
  617.  
  618. /* Print a message describing the meaning of the value of errno.  */
  619. extern void perror __P ((__const char *__s));
  620.  
  621. #ifdef    __USE_BSD
  622. extern int sys_nerr;
  623. extern char *sys_errlist[];
  624. #endif
  625. #ifdef    __USE_GNU
  626. extern int _sys_nerr;
  627. extern char *_sys_errlist[];
  628. #endif
  629.  
  630.  
  631. #ifdef    __USE_POSIX
  632. /* Return the system file descriptor for STREAM.  */
  633. extern int fileno __P ((FILE *__stream));
  634. #endif /* Use POSIX.  */
  635.  
  636.  
  637. #if (defined (__USE_POSIX2) || defined(__USE_SVID) || defined(__USE_BSD) || \
  638.      defined(__USE_MISC))
  639. /* Create a new stream connected to a pipe running the given command.  */
  640. extern FILE *popen __P ((__const char *__command, __const char *__modes));
  641.  
  642. /* Close a stream opened by popen and return the status of its child.  */
  643. extern int pclose __P ((FILE *__stream));
  644. #endif
  645.  
  646.  
  647. #ifdef    __USE_POSIX
  648. /* Return the name of the controlling terminal.  */
  649. extern char *ctermid __P ((char *__s));
  650. /* Return the name of the current user.  */
  651. extern char *cuserid __P ((char *__s));
  652. #endif
  653.  
  654.  
  655. #ifdef    __USE_GNU
  656. struct obstack;            /* See <obstack.h>.  */
  657.  
  658. /* Open a stream that writes to OBSTACK.  */
  659. extern FILE *open_obstack_stream __P ((struct obstack *__obstack));
  660.  
  661. /* Write formatted output to an obstack.  */
  662. extern int obstack_printf __P ((struct obstack *__obstack,
  663.                 __const char *__format, ...));
  664. extern int obstack_vprintf __P ((struct obstack *__obstack,
  665.                  __const char *__format,
  666.                  __gnuc_va_list __args));
  667. #endif
  668.  
  669.  
  670. __END_DECLS
  671.  
  672. #endif /* <stdio.h> included.  */
  673.  
  674. #endif /* stdio.h  */
  675.